def predict_gender():
    sentence = input_name_Text.get("1.0", "end-1c").strip()  # 获取输入的文本
    sentence = jieba.lcut(sentence)
    obs_seq = []
    # 将句子中的每个单词转化为对应的 ID，如果单词未知，则将其 ID 置为 -1
    for word in sentence:
        obs_seq.append(word2id.get(word, -1))
    # 如果句子中存在未知单词，则提示用户并跳过本次循环
    if -1 in obs_seq:
        pass
    # 使用前向-后向算法计算 gamma
    gamma = forward_backward(obs_seq, A, B)
    # 预测词性标注，即在每个时间步上选择具有最大后验概率的状态
    pos_tags_list = [pos_tags[i] for i in [max(range(pos_tag_count),
                                               key=lambda i: gamma[t][i]) for t in range(len(obs_seq))]]
    # 将句子中每个单词和对应的词性标注拼接成字符串并输出
    sex_Text.delete(1.0, tk.END)  # 清空预测性别显示框
    # 将预测性别显示在文本框中
    sex_Text.insert(1.0, " ".join([f"{word}/{pos_tag}" for word, pos_tag in zip(sentence, pos_tags_list)]))